@extends('user.base')
@section('content-body')
<section class="content">
	@if (count($errors) > 0)
	<div class="alert alert-danger">
		<strong>Whoops!</strong> There were some problems with your input.
		<br>
		<br>
		<ul>
			@foreach ($errors->all() as $error)
			<li>
				{{ $error }}
			</li>
			@endforeach
		</ul>
	</div>
	@endif
	<div class="container col-md-3 col-xs-3">
		<div class="row">
			<div id="user_info" class="col-md-6">
				<span>
					@if($user->avatar == null)
					<img title="user_pic" src='{{ asset('/img/avatar.png') }}' alt="..."/>
					@else
					<img title="user_pic" src='{{ asset("$user->avatar") }}' alt="..."/>					
					@endif
					
				</span>
			</div>
			<div class="col-md-6">
				<span>
					<h4>
						{{ $user->name or "NickName"}}
					</h4>
				</span>
				<span>
					<button class="btn btn-xs btn-primary" id="editAvatar" data-toggle="modal" data-target="#avatarModal">
						Edit
					</button>
				</span>
			</div>
		</div>
		<hr />
	</div>
	<div class="container col-md-6">
		<form action="{{ URL('user/info/'.$user->id)}}" method="post" accept-charset="utf-8">
			<input type="hidden" name="_token" value="{{ csrf_token()}}">
			<input type="hidden" name="_method" value="PUT">
			<div class="form-group">
				<label>User Name:</label>
				<input type="text" class="form-control" name="username" value="{{ $user->name }}" placeholder="Enter your nickname here" required="required">
			</div>
			<div class="form-group">
				<label>Email Address:</label>
				<input type="email" class="form-control" name="email" value="{{ $user->email }}" placeholder="Enter your valid email address" required="required">
			</div>
			<div class="form-group">
				<label>Password(Minimum 6 characters):</label>
				<input class="form-control" type="password" name="password" value="{{ $user->password }}" placeholder="" required="required">
			</div>
			<div class="form-group">
				<label>Confirm your password:</label>
				<input class="form-control"type="password" name="password_confirmation" value="{{ $user->password }}" placeholder="" required="required">
			</div>
			<div class="form-group">
				<label class="control-label">Hospital</label>
				<input class="form-control" type="text" name='hospital' value="{{ $user->hospital }}" placeholder="Enter hospital name here"/>
			</div>
			<div class="form-group">
				<label class="control-label">Address</label>
				<input class="form-control" type="text" name='address' value="{{ $user->address }}" placeholder="Enter hospital address here"/>
			</div>
			<button type="submit" class="btn btn-success">
				Update
			</button>
			<a href="/" class="btn btn-info">
				Cancel
			</a>
		</form>
	</div>
	<div class="modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" id="avatarModal">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal">
						<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
					</button>
					<h4 class="modal-title">
						Modify Avatar
					</h4>
				</div>
				<div class="modal-body">
					<form action="{{ URL('/user/avatar/'.$user->id)}}" accept-charset="utf-8" method="post" enctype="multipart/form-data">
						<input type="hidden" name="_token" value="{{ csrf_token()}}">
						<div class="form-group">
							<label class="control-label">Select</label>
							<input type="file" class="form-control" name="avatar"/>
						</div>
						<div class="form-group">
						<button type="button" class="btn btn-default" data-dismiss="modal">
							Cancel
						</button>
						<button type="submit" class="btn btn-primary" id="saveAvatar">
							Save
						</button>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</section>
@endsection